//图片轮播
let images = ["banner2.jpg", "banner1.jpg"];
let index = 0;
window.setInterval(function () {
    $("#switch-div").css("backgroundImage", "url(./img/goktech-img/images/" + images[index] + ")");
    // document.getElementById("switch-div").style.backgroundImage = "url(../img/goktech-img/images/" + images[index] +  ")";
    index++;
    if (index == images.length) {
        index = 0;
    }
}, 2000);

//主页下拉出现动画
$(".column-div ul>li:nth-child(2)").hover(function () {
    $(this).children("div").slideToggle(200);
});

//二维码出现动画
$(".header-div .ewm").hover(function () {
    $(".ewm-div").slideToggle(200);
});

//回到顶部
$(function () {
    $(window).scroll(function () {
        let slideHeight = $(window).scrollTop();
        if (slideHeight >= 200) {
            $(".broadside-nav div").css("backgroundColor", "#f5f5f5");
        }
        if (slideHeight > 500) {
            $(".broadside-nav .hidden-div").css("display", "block");
        } else {
            $(".broadside-nav .hidden-div").css("display", "none");
        }
    });
})

//联系客服弹窗动画
$(".broadside-nav .service-div").hover(function () {
    $(".broadside-nav .hidden-p").css("display", "block");
    $(".broadside-nav .hidden-p").animate({ "left": "-130px", "animation-timing-function": "ease" })
}, function () {
    $(".broadside-nav .hidden-p").css("display", "none");
    $(".broadside-nav .hidden-p").animate({ "left": "-155px", "animation-timing-function": "ease" })
});

//实现点击商品得到商品数据并跳转到商品页使用数据
let imgPath = "";
let goodsName = "";
let goodsPrice = "";

$(".European-style .parcel-div>a,.Modern .parcel-div>a,.xiangxun .parcel-div>a").on("click", function () {
    imgPath = $(this).children("img").attr("src");
    goodsName = $(this).siblings(".detail-div").children("span").html();
    goodsPrice = $(this).siblings(".price-div").children("span").html();

    localStorage.setItem("imgPath", imgPath);
    localStorage.setItem("goodsName", goodsName);
    localStorage.setItem("goodsPrice", goodsPrice);

    window.location = "ProgramJSP/details-of-goods.jsp";
});